package info.ensa.googlemapsandroidv2;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.Toast;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MyOverlays extends ItemizedOverlay<OverlayItem> {

	private OverlayItem overlays[] = new OverlayItem[1];

	// private ArrayList<OverlayItem> m_overlays = new ArrayList<OverlayItem>();

	private Context c;

	public MyOverlays(Drawable defaultMarker, MapView mapView) {

		super(boundCenterBottom(defaultMarker));

		c = mapView.getContext();

	}

	public void addOverlay(OverlayItem overlay) {

		overlays[0] = overlay;

		populate();

	}

	@Override
	protected OverlayItem createItem(int i) {

		return overlays[i];

	}

	@Override
	public int size() {

		return overlays.length;

	}

	@Override
	protected boolean onTap(int index) {

		OverlayItem overlayItem = overlays[index];

		Toast.makeText(c, overlayItem.getSnippet(), Toast.LENGTH_LONG)

		.show();

		return true;

	};

}
